package com.lollipop.programming.designpattern.proxy.jdk;

import lombok.extern.slf4j.Slf4j;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @Author Lollipop
 * @Version 1.0
 * @Date 2025/4/12 14:51
 * @Description JDK动态代理处理器
 */
@Slf4j
public class JDKDynamicProxyHandler implements InvocationHandler {
    private Object target;

    public JDKDynamicProxyHandler(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        log.info("============ JDK动态代理处理器 ============");
        log.info("JDK动态代理-前置处理");
        Object result = method.invoke(target, args);
        log.info("JDK动态代理-后置处理");
        return result;
    }
}
